const http = require('http')
const server = http.createServer()
server.on('request', (req, res) => {
    const query = new URL(req.url, 'http://127.0.0.1:3000').searchParams
    const callback = query.get('callback')
    if (callback) {
        let data = 'data'
        let result = `${callback}(${JSON.stringify(data)})`
        res.end(result)
    } else {
        res.end('hello jsonp')
    }
})
server.listen(3000, () => {
    console.log('server is running at http://127.0.0.1:3000')

})
